package com.zcxy.fast.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.zcxy.fast.bean.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import java.util.List;

/**
 * <p>
 * 平台用户表
 * </p>
 *
 * @author zcc
 * @since 2019-10-11
 */
@Data
@TableName(value = "sys_user")
@ApiModel(value = "User对象", description = "平台用户表")
public class SysUser extends BaseEntity {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "主键ID")
    @TableId(type = IdType.UUID)
    private String id;

    @ApiModelProperty(value = "登录名称")
    @NotBlank
    @Length(max = 32)
    @Pattern(regexp = "^[a-zA-Z][a-zA-Z0-9_]*$")
    private String loginName;

    @ApiModelProperty(value = "登录密码")
    @NotBlank
    @Pattern(regexp = "^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{8,32}$")
    private String password;

    @ApiModelProperty(value = "真实姓名")
    @NotBlank
    @Length(max = 100)
    private String realName;

    @ApiModelProperty(value = "性别(0男1女)")
    @Pattern(regexp = "[01]{1}$")
    private String sex;

    @ApiModelProperty(value = "手机号码")
    @Pattern(regexp = "^$|1[3-9][0-9]{9}$")
    private String phone;

    @ApiModelProperty(value = "邮箱")
    @Email
    @Length(max = 64)
    private String email;

    @ApiModelProperty(value = "备注")
    @Length(max = 512)
    private String remark;

    @ApiModelProperty(value = "角色ids,以,分割")
    private String roleIds;

    @ApiModelProperty(value = "图像路径")
    @Length(max = 255)
    private String avatar;

    @ApiModelProperty(value = "状态(0停用1正常)")
    @Pattern(regexp = "[01]{1}$")
    private String status;


    @ApiModelProperty(value = "加密盐")
    private String salt;

    @ApiModelProperty(value = "图像Url")
    @TableField(exist = false)
    private String avatarUrl;

    // private List<SysRole> roles;

    @TableField(exist = false)
    private String oldPassword;


    @TableField(exist = false)
    private String newPassword;

    @TableField(exist = false)
    private String confirmPassword;


    @TableField(exist = false)
    private List<SysAttachment> avatarAttachs;

}
